<template>
	<view class="mainpadding" v-if="pageShow">
		<view class="mainpadding ffffff shadow radius flextop">
			<image style="width: 230rpx;height: 170rpx;" :src="dataAll.carinfo.image_text" mode=""></image>
			<view class="flexcolumnbet" style="width: 60%;height: 170rpx;">
				<view class="titletext zhonghei fonweight xiankuan">{{dataAll.carinfo.name}}</view>
				<view class="strongtext xiaohui">{{dataAll.carinfo.sku2.difference}}</view>
				<view class="">
					<text class="strongtext xiaohong">￥</text>
					<text class="bigtext xiaohong fonweight">{{dataAll.pay_price}}</text>
				</view>
			</view>
		</view>
		<!-- <view class="mainpadding ffffff shadow radius margin_top ">
			<view class="flexbetween">
				<view class="ershiba zhonghei">用车方式</view>
				<view class="ershiba xiaohei">{{dataAll.carinfo.car_type==1?'租车':'买车'}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershiba zhonghei">租期</view>
				<view class="ershiba xiaohei">12个月</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershiba zhonghei">车况</view>
				<view class="ershiba xiaohei">良好</view>
			</view>
		</view> -->
		<input class="inputs margin_top" placeholder="请输入姓名" type="text" v-model="username"/>
		<input class="inputs margin_top" placeholder="请输入电话" type="number" v-model="tel"/>
		<view class="gudingdb mainpadding" @click="tzzzf">
			<view class="bigbtny">提交预定</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				lastmsg:{},
				dataAll:{},
				username:"",
				tel:"",
				pageShow:false
			}
		},
		onLoad(options) {
			this.lastmsg = JSON.parse(decodeURIComponent(options.msg));
			this.getdingdan()
		},
		methods: {
			getdingdan() {
				let data = this.lastmsg
				httpRequest.request("/api/carordercl/getOrderSure", 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						this.dataAll = res.data
						this.pageShow = true
					}
				})
			},
			// 跳转支付
			tzzzf() {
				if(this.username==""){
					httpRequest.toast("请输入姓名")
					return false
				}
				if(this.tel==""){
					httpRequest.toast("请输入电话")
					return false
				}
				httpRequest.request("/api/carordercl/addOrder", 'GET', {
					car_id:this.lastmsg.car_id,
					sku_id:this.lastmsg.sku_id,
					username:this.username,
					tel:this.tel,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let data = {
							order_id:res.data.order_id,
							pay_price:res.data.pay_price,
							pay_score:this.dataAll.score,
							type:1
						}
						uni.redirectTo({
							url: '/pages_index/zhifuTwo?msg='+encodeURIComponent(JSON.stringify(data))
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.inputs {
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		border: 2rpx solid #E8E8E8;
		padding: 25rpx 30rpx;
		background: #F2F2F2;
	}
</style>